package com.chat.io;

import javafx.scene.control.Button;
import javafx.stage.FileChooser;

import java.io.File;

/*
 选择图片的工具类
 */
public class SelectImage {
      public File select(Button Return){
            File file=null;
            FileChooser chooser=new FileChooser();
            chooser.setInitialDirectory(new File("D:\\chatproject\\headimage"));
            chooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Image Files","*.png","*.jpg","*.gif"));
            chooser.setTitle("选择图片");
            file=chooser.showOpenDialog(Return.getScene().getWindow());
            if(file==null){
                  System.out.println("未选择");
            }
            else{
                  System.out.println("成功选择");
            }
            return file;
      }
}
